<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>热卖商品添加</title>
    <script th:src="@{/js/jquery-3.6.0.js}"></script>
    <script th:src="@{/js/laydate/laydate.js}"></script>
    <script th:src="@{/js/layer/layer.js}"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

    <script>
        $(()=>{
            laydate.render({
                elem: '.time',
                type: 'datetime'
            });

            $("#selGoods").click(function () {
                layer.open({
                    type: 2,
                    title: '选择秒杀课程',
                    maxmin: false, //开启最大化最小化按钮
                    area: ['600px', '400px'],
                    content: '/page/courseSeckill/courseList',
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        //控制选择需要显示的秒杀课程的属性 √
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                        let course = iframeWin.getSelectedGoods();
                        $("#courseId").val(course.id);
                        $("#courseTitle").text("课程名："+course.name);
                        $("#coursePrice").text("课程价格："+course.price);
                        $("#lessonNum").text("课时数："+course.lesson_num);
                        layer.close(index);
                    }
                });
            });
        });
    </script>
<!--    <style>-->
<!--        body{-->
<!--            background-image: linear-gradient(45deg,red 0%,blue 50%);-->
<!--        }-->
<!--    </style>-->
</head>
<body>
    <div class="container">
        <div class="row" style="margin-top: 250px;">
            <div class="col-xs-6 col-sm-4"></div>
            <div class="col-xs-6 col-sm-4">
                <th:block th:text="${msg}" color="red"></th:block>
                <!--    修改秒杀课程属性 √-->
                <h3>秒杀课程添加</h3>
                <form th:action="@{/page/courseSeckill/add}" method="post" style="margin-top: 25px;">
                    热卖名称：<input name="name" type="text"/><br/><br/>
                    展示时间：<input name="showTime" type="text" class="time" readonly/><br/><br/>
                    开始时间：<input name="startTime" type="text" class="time" readonly/><br/><br/>
                    结束时间：<input name="endTime" type="text" class="time" readonly/><br/><br/>
                    <!--      更改课程显示属性 √-->
                    秒杀课程： <input type="button" value="选择课程" id="selGoods"><br/>
                    <input type="hidden" name="courseId" id="courseId">
                    <span id="courseTitle" style="color: red"></span>
                    <span id="coursePrice" style="color: red"></span>
                    <span id="lessonNum" style="color: red"></span>
                    <br>
                    热卖价格：<input name="seckillPrice" type="text"/><br/><br/>
                    秒杀数量：<input name="seckillNum" type="text"/><br/><br/>
                    <input type="submit" value="添加热卖"/>
                </form>
            </div>
            <!-- Optional: clear the XS cols if their content doesn't match in height -->
            <div class="clearfix visible-xs-block"></div>
            <div class="col-xs-6 col-sm-4"></div>
        </div>
    </div>
</body>
</html>